<template>
    <div id="parts">
        <div class="operation">
            <el-button v-if="menuId==='4552'" @click="insertList" class="slot-btn-top" type="primary" size="small">发放任务</el-button>
        </div>
        <el-table :data="dataList.slice((currentPage-1)*pagesize,currentPage*pagesize)" :highlight-current-row="true" stripe border class="table-index" :height="tableHeight" style="width: 100%;" :header-cell-style="getRowClass" v-loading="loading">
            <el-table-column fixed type="index" label="*" sortable min-width="40"></el-table-column>
            <el-table-column prop="taskcode" label="部件条码" sortable min-width="160"></el-table-column>
            <el-table-column prop="batchnums" label="生产批号" sortable min-width="120"></el-table-column>
            <el-table-column prop="resourcenameName" label="部装产品名称" sortable min-width="130"></el-table-column>
            <el-table-column prop="typenums" label="产品型号" sortable min-width="120"></el-table-column>
            <el-table-column prop="taskstartorendtime" label="任务需完成时间" sortable min-width="160"></el-table-column>
            <el-table-column prop="taskbegintime" label="开始启动时间" sortable min-width="160"></el-table-column>
            <el-table-column prop="taskendtime" label="任务结束时间" sortable min-width="160"></el-table-column>
            <el-table-column prop="state" label="状态" sortable min-width="160">
                <template slot-scope="scope">
                    <el-tag type="success" v-if="scope.row.state==1">合格</el-tag>
                    <el-tag type="danger" v-if="scope.row.state==0">不合格</el-tag>
                </template>
            </el-table-column>
            <el-table-column fixed="right" label="操作" sortable align="center" width="140">
                <template slot-scope="scope">
                    <el-button @click="updateList(scope.row)" type="text" size="small">编辑</el-button>
                     <el-button @click="printCode(scope.row.taskcode)" type="text" size="small">打印条码</el-button>
                </template>
            </el-table-column>
        </el-table>
        <el-pagination background @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page="currentPage" :page-sizes="[5,10, 15,20, 25,30,50, 100]" :page-size="pagesize" layout="total, sizes, prev, pager, next, jumper" :total="dataList.length"></el-pagination>

        <!-- 详情信息 -->
        <el-dialog :title="dialogTitle" width="90%" top="30px" :visible.sync="isDialog" :close-on-click-modal="false" v-dialogDrag>
            <el-tabs v-model="activeName" @tab-click="handleClick" style="padding-bottom: 15px;" >
                <el-tab-pane label="任务信息" name="1" class="dialog1" :style="dialogHeightPane" >
                    <h3 class="dialog-plate-title"><span>基本信息</span></h3>
                    <el-form :inline="true" class="demo-form-inline" v-model="dialogList" label-position="right" label-width="180px">
                        <el-form-item label="部件条码"><el-input v-model="dialogList.taskcode" :disabled="!dialogListDisabled.taskcode"></el-input></el-form-item>
                        <el-form-item label="生产批号"><el-input v-model="dialogList.batchnums" :disabled="!dialogListDisabled.batchnums"></el-input></el-form-item>
                        <el-form-item label="部装产品名称">
                            <el-select v-model="dialogList.resourcename" :disabled="!dialogListDisabled.resourcename">
                                <el-option v-for="item in productName" :key="item.id" :label="item.name" :value="item.id"></el-option>
                            </el-select>
                        </el-form-item>
                        <el-form-item label="产品型号"><el-input v-model="dialogList.typenums" :disabled="!dialogListDisabled.typenums"></el-input></el-form-item>
                        <el-form-item label="部装业务类型"><el-input v-model="dialogList.businesstype" :disabled="!dialogListDisabled.businesstype"></el-input></el-form-item>
                        <el-form-item label="任务创建人"><el-input v-model="dialogList.taskreleasepersonName" :disabled="!dialogListDisabled.taskreleasepersonName"></el-input></el-form-item>
                        <el-form-item label="任务创建时间">
                            <el-date-picker v-model="dialogList.taskreleaseaddtime" :disabled="!dialogListDisabled.taskreleaseaddtime" format="yyyy-MM-dd HH:mm:ss" type="datetime" placeholder="选择日期时间" style="width: 200px;"></el-date-picker>
                        </el-form-item>
                        <el-form-item label="负责人">
                            <el-select v-model="dialogList.taskperformperson" :disabled="!dialogListDisabled.taskperformperson">
                                <el-option v-for="item in charger" :key="item.id" :label="item.name" :value="item.id"></el-option>
                            </el-select>
                        </el-form-item>
                        <el-form-item label="任务需完成时间">
                            <el-date-picker v-model="dialogList.taskstartorendtime" :disabled="!dialogListDisabled.taskstartorendtime" format="yyyy-MM-dd HH:mm:ss" type="datetime" placeholder="选择日期时间" style="width: 200px;"></el-date-picker>
                        </el-form-item>
                        <el-form-item label="计划创建类型">
                            <el-select v-model="dialogList.tasktype" :disabled="!dialogListDisabled.tasktype">
                                <el-option label="计划任务" :value="1"></el-option>
                                <el-option label="临时任务" :value="2"></el-option>
                            </el-select>
                        </el-form-item>
                    </el-form>

                    <h3 class="dialog-plate-title"><span>待办信息</span></h3>
                    <el-form :inline="true" class="demo-form-inline" v-model="dialogList" label-position="right" label-width="180px">
                        <el-form-item label="任务是否接收">
                            <el-select v-model="dialogList.istaskstart" :disabled="!dialogListDisabled.istaskstart">
                                <el-option label="否" value="0"></el-option>
                                <el-option label="是" value="1"></el-option>
                            </el-select>
                        </el-form-item>
                        <el-form-item label="接收创建时间">
                            <el-date-picker v-model="dialogList.taskstartaddtime" :disabled="!dialogListDisabled.taskstartaddtime" format="yyyy-MM-dd HH:mm:ss" type="datetime" placeholder="选择日期时间" style="width: 200px;"></el-date-picker>
                        </el-form-item>
                    </el-form>

                    <h3 class="dialog-plate-title"><span>进行中信息</span></h3>
                    <el-form :inline="true" class="demo-form-inline" v-model="dialogList" label-position="right" label-width="180px">
                        <el-form-item label="任务是否开始">
                            <el-select v-model="dialogList.istaskbegin" :disabled="!dialogListDisabled.istaskbegin">
                                <el-option label="否" value="0"></el-option>
                                <el-option label="是" value="1"></el-option>
                            </el-select>
                        </el-form-item>
                        <el-form-item label="开始启动时间">
                            <el-date-picker v-model="dialogList.taskbegintime" :disabled="!dialogListDisabled.taskbegintime" format="yyyy-MM-dd HH:mm:ss" type="datetime" placeholder="选择日期时间" style="width: 200px;"></el-date-picker>
                        </el-form-item>
                        <el-form-item label="启动创建时间">
                            <el-date-picker v-model="dialogList.taskbeginaddtime" :disabled="!dialogListDisabled.taskbeginaddtime" format="yyyy-MM-dd HH:mm:ss" type="datetime" placeholder="选择日期时间" style="width: 200px;"></el-date-picker>
                        </el-form-item>
                        <el-form-item label="任务是否结束">
                            <el-select v-model="dialogList.istaskend" :disabled="!dialogListDisabled.istaskend">
                                <el-option label="否" value="0"></el-option>
                                <el-option label="是" value="1"></el-option>
                            </el-select>
                        </el-form-item>
                        <el-form-item label="任务结束时间">
                            <el-date-picker v-model="dialogList.taskendtime" :disabled="!dialogListDisabled.taskendtime" format="yyyy-MM-dd HH:mm:ss" type="datetime" placeholder="选择日期时间" style="width: 200px;"></el-date-picker>
                        </el-form-item>
                        <el-form-item label="结束创建时间">
                            <el-date-picker v-model="dialogList.taskendaddtime" :disabled="!dialogListDisabled.taskendaddtime" format="yyyy-MM-dd HH:mm:ss" type="datetime" placeholder="选择日期时间" style="width: 200px;"></el-date-picker>
                        </el-form-item>
                        <el-form-item label="是否已出库">
                            <el-select v-model="dialogList.isoutstorage" :disabled="!dialogListDisabled.isoutstorage">
                                <el-option label="否" :value="0"></el-option>
                                <el-option label="是" :value="1"></el-option>
                            </el-select>
                        </el-form-item>
                        <el-form-item label="状态">
                            <el-select v-model="dialogList.state" :disabled="!dialogListDisabled.state">
                                <el-option label="不合格" :value="0"></el-option>
                                <el-option label="合格" :value="1"></el-option>
                            </el-select>
                        </el-form-item>
                    </el-form>

                    <h3 class="dialog-plate-title"><span>复核信息</span></h3>
                    <el-form :inline="true" class="demo-form-inline" v-model="dialogList" label-position="right" label-width="180px">
                        <el-form-item label="任务是否复核">
                            <el-select v-model="dialogList.isreviewtask" :disabled="!dialogListDisabled.isreviewtask">
                                <el-option label="否" value="0"></el-option>
                                <el-option label="是" value="1"></el-option>
                            </el-select>
                        </el-form-item>
                        <el-form-item label="复核执行人"><el-input v-model="dialogList.reviewperson" :disabled="!dialogListDisabled.reviewperson"></el-input></el-form-item>
                        <el-form-item label="复核结果">
                            <el-select v-model="dialogList.reviewresult" :disabled="!dialogListDisabled.reviewresult">
                                <el-option label="【空】" value="-1"></el-option>
                                <el-option label="正常" value="1"></el-option>
                                <el-option label="异常" value="0"></el-option>
                            </el-select>
                        </el-form-item>
                        <el-form-item label="复核时间">
                            <el-date-picker v-model="dialogList.reviewtime" :disabled="!dialogListDisabled.reviewtime" format="yyyy-MM-dd HH:mm:ss" type="datetime" placeholder="选择日期时间" style="width: 200px;"></el-date-picker>
                        </el-form-item>
                        <el-form-item label="复核创建时间">
                            <el-date-picker v-model="dialogList.reviewaddtime" :disabled="!dialogListDisabled.reviewaddtime" format="yyyy-MM-dd HH:mm:ss" type="datetime" placeholder="选择日期时间" style="width: 200px;"></el-date-picker>
                        </el-form-item>
                    </el-form>
                    <div style="text-align: right">
                        <el-button @click="submitList" type="primary">确 定</el-button>
                    </div>
                </el-tab-pane>
                <el-tab-pane v-if="dialogType !== '1'"  label="物料输入" name="2" :style="dialogHeightPane">
                    <el-table :data="inputMateriel.list" stripe border class="table-index" :height="dialogTableHeight" style="width: 100%;" :header-cell-style="getRowClass">
                        <el-table-column fixed type="index" label="*" sortable min-width="40"></el-table-column>
                        <el-table-column prop="nameName" label="物料名称" sortable min-width="170"></el-table-column>
                        <el-table-column prop="code" label="物料条码" sortable min-width="170"></el-table-column>
                        <el-table-column prop="num" label="数量" sortable min-width="100"></el-table-column>
                        <el-table-column prop="isAssembly" label="是否领料"  :formatter='formartIsAssembly' sortable min-width="100"></el-table-column>
                        <el-table-column fixed="right" label="操作" sortable align="center" width="75">
                            <template slot-scope="scope">
                                <el-button @click="showDialog1('update',scope.row)" type="text" size="small">查看物料</el-button>
                            </template>
                        </el-table-column>
                    </el-table>
                    <el-pagination background @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page="inputMateriel.pagination.currentPage" :page-sizes="[5,10, 15,20, 25,30,50, 100]" :page-size="inputMateriel.pagination.pageSize" layout="total, sizes, prev, pager, next, jumper" :total="inputMateriel.pagination.total"></el-pagination>
                </el-tab-pane>
                <el-tab-pane v-if="dialogType !== '1'"  label="装配过程" name="3" :style="dialogHeightPane">
                    <h3 class="dialog-plate-title"><span>装配过程过程信息录入</span></h3>
                        <div class="formDemo">
                            <div v-for="item in assembly.list" :key="item.id" class="formItem">
                                <label v-text="item.name+':'" class="formItemLabel"></label>
                                <el-input v-model="item.value" v-if="item.type==0" :disabled="assembly.disabled" class="formInput"></el-input>
                                <el-select v-model="item.value" v-else-if="item.type==1" placeholder="请选择" class="inputSelect" :disabled="assembly.disabled">
                                    <el-option :label="item.reference" value="1"></el-option>
                                    <el-option label="否" value="0"></el-option>
                                </el-select>
                                <!-- <el-radio-group v-model="item.value" v-else-if="item.type==1" :disabled="assembly.disabled">
                                    <el-radio :label="'1'">{{item.reference}}</el-radio>
                                    <el-radio :label="'0'">否</el-radio>
                                </el-radio-group> -->
                                <el-input placeholder="请输入内容" v-model="item.value" v-else-if="item.type==2" :disabled="assembly.disabled" class="formInput">
                                    <el-button slot="append">{{item.unit}}</el-button>
                                </el-input>
                                <span class="reference">（参考值:{{item.reference}}）</span>
                            </div>
                        </div>
                     <div  class="text-center">
                        <el-button  type="primary" @click="assemblyUpdate" :loading="assembly.submitLoading">{{assembly.disabled?'录入':'提交'}}</el-button>
                    </div>
                </el-tab-pane>
                 <el-tab-pane v-if="dialogType !== '1'"  label="输出结果" name="4" :style="dialogHeightPane">
                     <el-button  @click="addResult()" class="slot-btn-top" type="primary" size="small">新增输出结果</el-button>
                     <el-table :data="result.list" stripe border class="table-index" :height="dialogTableHeight" style="width: 100%;" :header-cell-style="getRowClass">
                        <el-table-column fixed type="index" label="*" sortable min-width="40"></el-table-column>
                        <el-table-column prop="name" label="名称"    sortable min-width="170"></el-table-column>
                        <el-table-column prop="jqbzResults.length" label="检查项数量"    sortable min-width="170"></el-table-column>
                        <el-table-column prop="createTime" label="创建时间"   sortable min-width="100"></el-table-column>
                        <el-table-column prop="creator" label="创建人"   sortable min-width="100"></el-table-column>
                        <el-table-column fixed="right" label="操作" sortable align="center" width="160">
                            <template slot-scope="scope">
                                <el-button @click="showDialog1('update',scope.row)" type="text" size="small">编辑</el-button>
                            </template>
                        </el-table-column>
                    </el-table>
                </el-tab-pane>
                <el-tab-pane v-if="dialogType !== '1'"  label="出库记录" name="5" :style="dialogHeightPane">
                     <el-table :data="checkOut.list" stripe border class="table-index" :height="dialogTableHeight" style="width: 100%;" :header-cell-style="getRowClass">
                        <el-table-column fixed type="index" label="*" sortable min-width="40"></el-table-column>
                        <el-table-column prop="code" label="总装机器编号" sortable min-width="170"></el-table-column>
                        <el-table-column prop="state" label="状态" sortable min-width="170">
                              <template slot-scope="scope">
                                <el-tag type="success" v-if="scope.row.state==1">合格</el-tag>
                               <el-tag type="danger" v-if="scope.row.state==0">不合格</el-tag>
                            </template>
                        </el-table-column>
                        <el-table-column prop="createTime" label="创建时间" sortable min-width="170"></el-table-column>
                         <el-table-column prop="creatorName" label="领料人" sortable min-width="170"></el-table-column>
                        <el-table-column prop="recorderName" label="总装记录" sortable min-width="170"></el-table-column>
                        <el-table-column fixed="right" label="操作" sortable align="center" width="75">
                            <template slot-scope="scope">
                                <el-button @click="showDialog1('',scope.row)" type="text" size="small">检验记录</el-button>
                            </template>
                        </el-table-column>
                    </el-table>
                </el-tab-pane>
                <el-tab-pane v-if="dialogType !== '1'"  label="技术标准" name="6" :style="dialogHeightPane">
                    <el-table  :data="technicalStandard" tooltip-effect="dark"  style="width: 100%" >
                        <el-table-column prop="fileName" label="文件名称"> </el-table-column>
                        <el-table-column fixed="right" label="操作" sortable align="center" width="160">
                            <template slot-scope="scope">
                                <el-button @click="showDialog1('watch',scope.row)" type="text" size="small">查看</el-button>
                            </template>
                        </el-table-column>
                    </el-table>
                </el-tab-pane>
                <el-tab-pane v-if="dialogType !== '1'"  label="图纸" name="7" :style="dialogHeightPane">
                    <el-table  :data="drawingList" tooltip-effect="dark"  style="width: 100%" >
                        <el-table-column prop="drawingName" label="图纸名称"> </el-table-column>
                         <el-table-column fixed="right" label="操作" sortable align="center" width="160">
                            <template slot-scope="scope">
                                <el-button @click="showDialog1('watch',scope.row)" type="text" size="small">查看</el-button>
                            </template>
                        </el-table-column>
                    </el-table>
                </el-tab-pane>
                <el-tab-pane v-if="dialogType !== '1'"  label="SOP" name="8" :style="dialogHeightPane">
                    <el-table  :data="sopList" tooltip-effect="dark"  style="width: 100%" >
                        <el-table-column prop="fileName" label="SOP名称"> </el-table-column>
                        <el-table-column fixed="right" label="操作" sortable align="center" width="160">
                            <template slot-scope="scope">
                                <el-button @click="showDialog1('watch',scope.row)" type="text" size="small">查看</el-button>
                            </template>
                        </el-table-column>
                    </el-table>
                </el-tab-pane>
            </el-tabs>
        </el-dialog>
        <el-dialog :title="dialog1.title" width="90%" top="30px" :visible.sync="dialog1.isShow" :close-on-click-modal="false" v-dialogDrag>
            <div class="" :style="dialogHeightPane" v-if="activeName==2">
                <el-button  @click="showDialog2('add')" class="slot-btn-top" type="primary" size="small">领料</el-button>
                <el-table :data="inputMateriel.selectMaterieList" stripe border class="table-index" :height="dialogTableHeight" style="width: 100%;" :header-cell-style="getRowClass">
                        <el-table-column fixed type="index" label="*" sortable min-width="40"></el-table-column>
                        <el-table-column fixed prop="nameName" label="物料名称" sortable min-width="100"></el-table-column>
                        <el-table-column prop="type" label="产品型号"  min-width="100"></el-table-column>
                        <el-table-column prop="code" label="条码"  min-width="80"></el-table-column>
                        <el-table-column prop="batch" label="批号"  min-width="80"></el-table-column>
                        <el-table-column prop="num" label="数量"  min-width="50"></el-table-column>
                        <el-table-column prop="creatorName" label="领料人"  min-width="60"></el-table-column>
                        <el-table-column prop="state" label="物料状态" min-width="60">
                             <template slot-scope="scope">
                               <el-tag type="success" v-if="scope.row.state==1">合格</el-tag>
                               <el-tag type="danger" v-if="scope.row.state==0">不合格</el-tag>
                               <el-tag type="info" v-if="scope.row.state==-1">报废</el-tag>
                            </template>
                        </el-table-column>
                        <el-table-column prop="createTime" label="领料时间" sortable min-width="100"></el-table-column>
                        <el-table-column fixed="right" label="操作" sortable align="center" width="120">
                            <template slot-scope="scope">
                                <el-button @click="showDialog2('insert',scope.row)" type="text" size="small">检验</el-button>
                                <el-button @click="deleteSelectMaterie(scope.row)" type="text" size="small">删除</el-button>
                                 <el-button @click="printCode(scope.row.code)" type="text" size="small" v-if="scope.row.code">打印条码</el-button>
                            </template>
                        </el-table-column>
                </el-table>
            </div>
             <div class="" :style="dialogHeightPane" v-if="activeName==3">

            </div>
             <div class="" :style="dialogHeightPane" v-if="activeName==4">
                  <el-form  :inline="true" class="demo-form-inline"  label-position="right">
                        <!-- <el-form-item label="照片" class="cameraItem">
                            <div class="cameraContent">
                                <img :src="inputMateriel.checkMaterial.photoPath" alt="" v-if="inputMateriel.checkMaterial.photoPath">
                                <span @click="showDialog3('camera')">拍照上传</span>
                            </div>
                        </el-form-item> -->
                          <el-form-item :label="item.name" v-for="item in result.dialogForm" :key="item.id" class="input100">
                            <el-input v-model="item.value" v-if="item.type==0"  class="inputSuffix"></el-input>
                            <el-select v-model="item.value" v-else-if="item.type==1" placeholder="请选择" class="inputSelect">
                                <el-option :label="item.reference" value="1"></el-option>
                                <el-option label="否" value="0"></el-option>
                            </el-select>
                            <el-input placeholder="请输入内容" v-model="item.value" v-else-if="item.type==2"  class="inputSuffix">
                                <el-button slot="append">{{item.unit}}</el-button>
                            </el-input>
                            <span class="reference" v-if="item.remark">（备注：{{item.remark}}）</span>
                        </el-form-item>
                    <div style="text-align: center">
                        <el-button @click="updateResulte" type="primary">确 定</el-button>
                    </div>
                </el-form>
            </div>
            <div class="" :style="dialogHeightPane" v-if="activeName==5">
                 <el-form  :inline="true" class="demo-form-inline" :model="checkOut.dialogForm" label-position="right" label-width="180px">
                         <el-form-item label="照片" class="cameraItem">
                            <div class="cameraContent">
                                <img :src="checkOut.dialogForm.path" alt="" v-if="checkOut.dialogForm.path">
                            </div>
                        </el-form-item>
                         <el-form-item label="外观">
                              <el-select v-model="checkOut.dialogForm.appearance" placeholder="请选择" disabled>
                                <el-option label="合格" value="1"> </el-option>
                                <el-option label="不合格" value="0"></el-option>
                            </el-select>
                        </el-form-item>
                        <el-form-item label="尺寸">
                            <el-select v-model="checkOut.dialogForm.size" placeholder="请选择" disabled>
                                <el-option label="合格" value="1"> </el-option>
                                <el-option label="不合格" value="0"></el-option>
                            </el-select>
                        </el-form-item>
                        <el-form-item label="性能">
                            <el-select v-model="checkOut.dialogForm.performance" placeholder="请选择" disabled>
                                <el-option label="合格" value="1"> </el-option>
                                <el-option label="不合格" value="0"></el-option>
                            </el-select>
                        </el-form-item>
                            <el-form-item label="是否符合装配要求">
                            <el-select v-model="checkOut.dialogForm.assembly" placeholder="请选择" disabled>
                            <el-option label="符合" value="1"> </el-option>
                            <el-option label="不符合" value="0"></el-option>
                        </el-select>
                        </el-form-item>
                        <el-form-item label="结果">
                            <el-select v-model="checkOut.dialogForm.result" placeholder="请选择" disabled>
                                <el-option label="合格" value="1"> </el-option>
                                <el-option label="不合格" value="0"></el-option>
                            </el-select>
                        </el-form-item>
                         <el-form-item label="创建人">
                            <el-input v-model="checkOut.dialogForm.creatorName" disabled></el-input>
                        </el-form-item>
                        <el-form-item label="创建时间">
                            <el-input v-model="checkOut.dialogForm.createTime" disabled></el-input>
                        </el-form-item>
                        <el-form-item label="备注" class="textareaWith100">
                            <el-input type="textarea" v-model="checkOut.dialogFormremark" disabled></el-input>
                        </el-form-item>
                </el-form>
            </div>
            <div v-if="activeName==6||activeName==8">
                <div v-html="dialog1.content"></div>
            </div>
            <div v-if="activeName==7">
                <el-input v-model.number="drawingPdf.instructionsPageApply" type="number" style="width: 100px;" min="1"
                    :max="drawingPdf.instructionsNumPagesApply"></el-input>
                <span>/{{drawingPdf.instructionsNumPagesApply}}</span>
                <el-button @click="drawingPdf.instructionsRotateApply += 90">&#x27F3;</el-button>
                <pdf ref="applyInstructionsPdf"
                        style="border: 1px solid red;"
                        :src="drawingPdf.src"
                        :page="drawingPdf.instructionsPageApply"
                        :rotate="drawingPdf.instructionsRotateApply"
                        @progress="drawingPdf.instructionsLoadedRatioApply = $event"
                        @num-pages="drawingPdf.instructionsNumPagesApply = $event"
                        @link-clicked="drawingPdf.instructionsPageApply = $event">
                </pdf>
            </div>
        </el-dialog>
        <el-dialog :title="dialog2.title" width="400" top="30px" :visible.sync="dialog2.isShow" :close-on-click-modal="false" v-dialogDrag>
            <div class="" :style="dialogHeightPane" v-if="dialog2.title=='领料'">
                  <el-table ref="multipleTable" highlight-current-row @current-change="handleCurrentChange1" :data="inputMateriel.allList" tooltip-effect="dark" style="width: 100%">
                    <el-table-column label="选择" width="50" align="center">
                        <template slot-scope="scope">
                            <el-radio class="radio"  v-model="inputMateriel.dialogForm.name"  :label="scope.row.tid">&nbsp;</el-radio>
                        </template>
                    </el-table-column>
                    <el-table-column label="物料名称" prop="resourcenameName"></el-table-column>
                    <el-table-column label="令号" prop="taskcode"></el-table-column>
                    <el-table-column label="物料库存" prop="remainingnums"></el-table-column>
                </el-table>
                <el-form :inline="true" :model="inputMateriel.dialogForm" class="demo-form-inline" style='margin-top:24px;'>
                    <el-form-item label="领料数量">
                        <el-input v-model="inputMateriel.dialogForm.num" placeholder="请输入领料数量"></el-input>
                    </el-form-item>
                </el-form>
                <div style="text-align: center;margin-top:24px;">
                    <el-button  type="primary" @click="addMateriel">确 定</el-button>
                </div>
            </div>
            <div class="" :style="dialogHeightPane" v-else>
                 <el-form  :inline="true" class="demo-form-inline" :model="inputMateriel.checkMaterial" label-position="right">
                        <!-- <el-form-item label="照片" class="cameraItem">
                            <div class="cameraContent">
                                <img :src="inputMateriel.checkMaterial.photoPath" alt="" v-if="inputMateriel.checkMaterial.photoPath">
                                <span @click="showDialog3('camera')">拍照上传</span>
                            </div>
                        </el-form-item> -->
                          <el-form-item :label="item.name" v-for="item in inputMateriel.checkMaterial.list" :key="item.id" class="input100">
                             <el-input v-model="item.value" v-if="item.type==0"  class="inputSuffix"></el-input>
                               <el-select v-model="item.value" v-else-if="item.type==1" placeholder="请选择" class="inputSelect">
                                    <el-option :label="item.reference" value="1"></el-option>
                                    <el-option label="否" value="0"></el-option>
                                </el-select>
                                <el-input placeholder="请输入内容" v-model="item.value" v-else-if="item.type==2" class="inputSuffix" >
                                    <el-button slot="append">{{item.unit}}</el-button>
                                </el-input>
                                <span class="reference" v-if="item.remark">（备注：{{item.remark}}）</span>
                        </el-form-item>
                    <div style="text-align: right">
                        <el-button @click="updateMaterialCheck" type="primary">确 定</el-button>
                    </div>
                </el-form>

            </div>
        </el-dialog>
        <y-camera :isShow="camera.isShow"></y-camera>

    </div>
</template>

<script>
import pdf from 'vue-pdf';
import api from '@/axios/api.js'
import YCamera from '@/components/common/camera.vue'
import {getLodop} from 'static/js/LodopFuncs'
export default {
        name: "",
        components:{
            YCamera,
            pdf
        },
        data() {
            let menuId = sessionStorage.getItem('menuId');
            let tableHeight = menuId === '4552' ? (document.documentElement.clientHeight - 170) : (document.documentElement.clientHeight - 140);
            return {
                /** pdf*/
                drawingPdf:{
                    src:'',
                    instructionsPageApply:1,
                    instructionsNumPagesApply: 0,
                    instructionsRotateApply: 0,
                },
                type:'',
                menuId,
                loading:false,/**加载中 */
                currentPage: 1,
                pagesize: 10,
                activeName: '1',
                productName:[],
                charger:[],
                tableHeight: tableHeight,
                dataList: [],
                //基本信息
                isDialog: false,
                dialogTitle: '',
                dialogType:'',
                dialogHeightPane: {
                    height: (document.documentElement.clientHeight - 180) + 'px',
                    overflowY: 'auto'
                },
                dialogTableHeight: document.documentElement.clientHeight - 260,
                dialogList:{
                    taskcode:"",
                    batchnums:"",
                    resourcename:"",
                    resourcenameName:"",
                    typenums:"",
                    businesstype:"",
                    taskreleaseperson:"",
                    taskreleasepersonName:"",
                    taskreleaseaddtime:"",
                    taskperformperson:"",
                    taskperformpersonName:"",
                    taskstartorendtime:"",
                    tasktype:"",
                    istaskstart:"",
                    taskstartaddtime:"",
                    istaskbegin:"",
                    taskbegintime:"",
                    taskbeginaddtime:"",
                    istaskend:"",
                    taskendtime:"",
                    taskendaddtime:"",
                    isoutstorage:"",
                    state:'',
                    isreviewtask:"",
                    reviewperson:"",
                    reviewresult:"",
                    reviewtime:"",
                    reviewaddtime:"",
                    mid:"",
                    reviewpersonName:"",
                    taskfinishstate:"",
                    taskstate:"",
                    tid:"",
                },
                taskReception:true,
                dialogListDisabled:{
                    taskcode:false,
                    batchnums:false,
                    resourcename:false,
                    resourcenameName:false,
                    typenums:false,
                    businesstype:false,
                    taskreleaseperson:false,
                    taskreleasepersonName:false,
                    taskreleaseaddtime:false,
                    taskperformperson:false,
                    taskperformpersonName:false,
                    taskstartorendtime:false,
                    tasktype:false,
                    istaskstart:false,
                    taskstartaddtime:false,
                    istaskbegin:false,
                    taskbegintime:false,
                    taskbeginaddtime:false,
                    istaskend:false,
                    taskendtime:false,
                    taskendaddtime:false,
                    isoutstorage:false,
                    state:false,
                    isreviewtask:false,
                    reviewperson:false,
                    reviewresult:false,
                    reviewtime:false,
                    reviewaddtime:false,
                    mid:false,
                    reviewpersonName:false,
                    taskfinishstate:false,
                    taskstate:false,
                    tid:false,
                },
                technicalStandard:[],/**技术标准 */
                drawingList:[],/**图纸列表 */
                sopList:[],/**sop列表 */
                inputMateriel:{/**物料输入*/
                    allList:[],/**所有物料 */
                    list:[],/**物料输入列表 */
                    selectMaterieList:[],/**入库物料 */
                    pagination:{/**分页 */
                        pageSize:10,
                        currentPage:1,
                        total:0
                    },
                    dialogForm:{
                        num:1,
                        pid:'',
                        name:''
                    },
                    checkMaterial:{
                        list:[]
                    },
                    checkMaterialId:'',
                },
                assembly:{/**装配记录 */
                    list:[],
                    dialogForm:{},
                    disabled:true,
                    submitLoading:false
                },
                result:{/**结果记录 */
                    list:[],
                    dialogForm:{}
                },
                checkOut:{
                    list:[],/**出库记录 */
                    dialogForm:{},
                },
                dialog1:{
                    title:'',
                    isShow:false,
                    content:''
                },
                dialog2:{
                    title:'',
                    isShow:false
                },
                dialog3:{
                    title:'',
                    isShow:false
                },
                camera:{
                    isShow:false
                }
            };
        },
        created() {
            this.getData();
            this.getCharger();
            this.getProductName();
        },
        methods: {
            assemblyFormatter(row, column, cellValue, index){
                return cellValue == 1 ? '符合' : (cellValue == 0 ? '不符合' : '')
            },
            resultFormatter(row, column, cellValue, index){
                return cellValue == 1 ? '合格' : (cellValue == 0 ? '不合格' : '')
            },
            formartIsAssembly(row, column, cellValue, index){
                return cellValue == 1 ? '是' : (cellValue == 0 ? '否' : '')
            },
            inputMaterielList(){
                let self = this;
                // 获取输入物料列表
                api.inputMaterielList(self.dialogList.tid).then(res=>{
                    self.inputMateriel.list = res.content;
                })
            },
            getTec(){/**获取技术标准列表 */
                let self=this;
                api.technicalStandard(self.dialogList.resourcename).then(res=>{
                self.technicalStandard=res.content;
                })
            },
            getDrawingList(){/**获取图纸列表 */
                let self=this;
                api.drawingList(self.dialogList.resourcename).then(res=>{
                    self.drawingList=res.content;
                })
            },
            getSOPList(){/**获取sop列表 */
                let self=this;
                api.SOPList(self.dialogList.resourcename).then(res=>{
                    self.sopList=res.content;
                })
            },
            getCharger() {/**获取任务人列表 */
                let _this = this;
                api.selectTaskPerformPerson().then(res=>{
                    _this.charger = res.content;
                })
            },
            getProductName() {/**获取部装产品列表 */
                let _this = this;
                    api.selectJqMbParts().then(res=>{
                        _this.productName = res.content;
                    });
            },
            /** 获取对应物料下的所有库存物料*/
            getMaterieListStore(id){
                let self= this;
                api.materieListStore(id).then(res=>{
                    res.content.forEach(element => {
                        element.value=element.resourcenameName;
                    });
                   self.inputMateriel.allList=res.content;
                })
            },
            /** 获取选择原料库中的原料*/
            getSelectMaterieList(id){
                let self= this;
                api.selectMaterieList(id).then(res=>{
                   self.inputMateriel.selectMaterieList=res.content;
                })
            },
            /** 获取装配记录列表*/
            getAssemblyList(){
                let self = this;
                api.assemblyList(self.dialogList.tid).then(res=>{
                    self.assembly.list=res.content;
                })
            },
            /** 获取结果输出列表*/
            getResulteList(){
                let self = this;
                api.resultList(self.dialogList.tid).then(res=>{
                   self.result.list=res.content;
                })
            },
            getCheckOutList(){/**获取出库记录列表 */
                let self = this;
                api.checkoutList(self.dialogList.tid).then(res=>{
                    self.checkOut.list=res.content;
                })
            },
            getData() {/**获取部装任务列表 */
                let self = this;
                let id;
                self.loading=true;
                api.selectUnqualifiedParts().then(res=>{
                     self.dataList = res.content;
                     self.loading=false;
                })
            },
            insertList(){
                this.isDialog = true;
                this.dialogType='1';
                this.dialogListDisabled={
                    taskcode:false,
                    batchnums:true,
                    resourcename:true,
                    typenums:true,
                    businesstype:true,
                    taskreleaseperson:false,
                    taskreleasepersonName:false,
                    taskreleaseaddtime:false,
                    taskperformperson:true,
                    taskperformpersonName:true,
                    taskstartorendtime:true,
                    tasktype:true,
                    istaskstart:false,
                    taskstartaddtime:false,
                    istaskbegin:false,
                    taskbegintime:false,
                    taskbeginaddtime:false,
                    istaskend:false,
                    taskendtime:false,
                    taskendaddtime:false,
                    isoutstorage:false,
                    state:false,
                    isreviewtask:false,
                    reviewperson:false,
                    reviewresult:false,
                    reviewtime:false,
                    reviewaddtime:false,
                    mid:false,
                    reviewpersonName:false,
                    taskfinishstate:false,
                    taskstate:false,
                    tid:false,
                };
                this.dialogList={
                    taskcode:"",
                    batchnums:"",
                    resourcename:"",
                    typenums:"",
                    businesstype:"",
                    taskreleaseperson:"",
                    taskreleasepersonName:"",
                    taskreleaseaddtime:"",
                    taskperformperson:"",
                    taskperformpersonName:"",
                    taskstartorendtime:"",
                    tasktype:"",
                    istaskstart:"",
                    taskstartaddtime:"",
                    istaskbegin:"",
                    taskbegintime:"",
                    taskbeginaddtime:"",
                    istaskend:"",
                    taskendtime:"",
                    taskendaddtime:"",
                    isoutstorage:"",
                    state:'',
                    isreviewtask:"",
                    reviewperson:"",
                    reviewresult:"",
                    reviewtime:"",
                    reviewaddtime:"",
                    mid:"",
                    reviewpersonName:"",
                    taskfinishstate:"",
                    taskstate:"",
                    tid:"",
                };
            },
            updateList(row) {
                this.isDialog = true;
                this.dialogType='2';
                this.activeName = '1';
                this.dialogListDisabled = {
                    taskcode: false,
                    batchnums:this.menuId==='4552' ? true : false,
                    resourcename:this.menuId==='4552' ? true : false,
                    typenums:this.menuId==='4552' ? true : false,
                    businesstype:this.menuId==='4552' ? true : false,
                    taskreleaseperson:false,
                    taskreleasepersonName:false,
                    taskreleaseaddtime:false,
                    taskperformperson:this.menuId==='4552' ? true : false,
                    taskperformpersonName:this.menuId==='4552' ? true : false,
                    taskstartorendtime:this.menuId==='4552' ? true : false,
                    tasktype:this.menuId==='4552' ? true : false,
                    istaskstart:this.menuId==='4552' ? true : false,
                    taskstartaddtime:false,
                    istaskbegin: this.menuId==='4553' ? true : false,
                    taskbegintime: this.menuId==='4553' ? true : false,
                    taskbeginaddtime:false,
                    istaskend: this.menuId==='4553' ? true : false,
                    taskendtime: this.menuId==='4553' ? true : false,
                    taskendaddtime:false,
                    isoutstorage: false,
                    state:false,
                    isreviewtask: this.menuId==='4554' ? true : false,
                    reviewperson:false,
                    reviewresult:this.menuId==='4554' ? true : false,
                    reviewtime:this.menuId==='4554' ? true : false,
                    reviewaddtime:false,
                    mid:false,
                    reviewpersonName:false,
                    taskfinishstate:false,
                    taskstate:false,
                    tid:false,
                };
                this.dialogList = row;
                this.dialogList.taskperformperson = parseInt(this.dialogList.taskperformperson);
                this.dialogList.resourcename = parseInt(this.dialogList.resourcename);
            },
            submitList(){
                let _this = this;
                _this.dialogList.taskstartorendtime = _this.timestampToTime(_this.dialogList.taskstartorendtime );
                _this.dialogList.taskbegintime = _this.timestampToTime(_this.dialogList.taskbegintime );
                _this.dialogList.taskendtime = _this.timestampToTime(_this.dialogList.taskendtime );
                _this.dialogList.reviewtime = _this.timestampToTime(_this.dialogList.reviewtime );

                let type=_this.dialogType==='1'?'insert':'update';
                debugger;
                api.addUpdataBZtask(type,_this.dialogList).then(res=>{
                    _this.isDialog = false;
                       _this.getData();
                         _this.$message.success("成功");
                },error=>{
                    _this.$message.error("加载失败！请重新加载...");
                })
            },
            handleClick(tab, event) {
                let self = this;
                 switch(self.activeName){
                    case '1':
                    break;
                    case '2':
                        self.inputMaterielList()
                    break;
                    case '3':
                        self.getAssemblyList();
                    break;
                    case '4':
                        self.getResulteList();
                    break;
                    case '5':
                        self.getCheckOutList();
                        break;
                    case '6':
                        self.getTec();
                    break;
                     case '7':
                        self.getDrawingList();
                    break;
                    case '8':
                        self.getSOPList();
                    break;


                }
            },
            showDialog1(type,row){
               let self = this;
               self.dialog1.isShow=true;
                switch(self.activeName){
                    case '1':
                        break;
                         case '2':
                            self.dialog1.title="物料入库";
                            self.inputMateriel.dialogForm.pid=row.id;
                            self.getMaterieListStore(row.name);
                            self.getSelectMaterieList(self.inputMateriel.dialogForm.pid);

                        break;
                         case '3':
                            self.dialog1.title=type=='add'?"添加装配过程":"修改装配过程";
                            self.assembly.dialogForm=type=='add'?{}:row;
                        break;
                         case '4':
                            self.dialog1.title="修改输出结果";
                            self.result.dialogForm= row.jqbzResults;
                        break;
                        case '5':
                            self.dialog1.title='检验记录'
                            api.checkOutCheackInfo(row.mid).then(res=>{
                                self.checkOut.dialogForm=res.content[0];

                            });
                        break;
                        case '6':
                        case '8':
                            self.dialog1.title=row.fileName;
                            self.dialog1.content=row.initialContent;
                        break;
                        case '7':
                            self.dialog1.title=row.drawingName;
                            self.drawingPdf.src=`http://192.168.0.93:8889/adscm/zltx/jyDrawingList/viewDrawingPdf/${row.id}/${row.drawingType}`;
                            self.drawingPdf.instructionsRotateApply=0;
                        break;
                }
            },
            showDialog2(type,row){
                let self = this;
                if(type=='add'){
                    self.dialog2.title="领料";
                    self.dialog2.isShow=true;
                    self.inputMateriel.dialogForm.num=1;
                    self.inputMateriel.dialogForm.name='';
                }else{
                     self.dialog2.title="检验";
                    self.dialog2.isShow=true;
                    self.inputMateriel.checkMaterialId=row.id;
                    self.materialListCheck(row.id);
                }
            },
            addMateriel(){
                let self = this;
                api.addMaterieStore(self.inputMateriel.dialogForm).then(res=>{
                    self.dialog2.isShow=false;
                    self.getSelectMaterieList(self.inputMateriel.dialogForm.pid);
                    self.inputMaterielList();
                    self.$message.success(`${self.dialog1.title}成功`)
                })
            },
            materialListCheck(pid){/**获取检验记录 */
            let self= this;
            //
            api.materialListCheck(pid).then(res=>{
                res.content.forEach(el=>{
                    if(el.type==1){
                        el.value=el.value?el.value:'1';
                    }
                })
               self.inputMateriel.checkMaterial.list=res.content;
            })
            },
            assemblyUpdate(){
                let self=this;
                if(self.assembly.disabled){
                    self.assembly.disabled=!self.assembly.disabled;
                }else{
                    self.assembly.submitLoading=true;
                    api.updateAssembly(self.assembly.list).then(res=>{
                        self.assembly.submitLoading=false;
                        self.$message.success("装配过程检测信息录入成功！");
                        self.getAssemblyList();
                        self.assembly.disabled=!self.assembly.disabled;
                    },error=>{
                        self.assembly.submitLoading=false;
                        self.$message.error("装配过程检测信息录入失败！");
                    })
                }
            },
            updateResulte(){
                 let self = this;
                 debugger;;
                 self.result.dialogForm;
                api.addUpdateReult('update',self.result.dialogForm).then(res=>{
                    self.dialog1.isShow=false;
                    self.getResulteList();
                    self.$message.success(`${self.dialog1.title}成功`)
                },error=>{
                    self.$message.error(`${self.dialog1.title}失败`)
                })
            },
            querySearchAsync(queryString, cb) {
                var restaurants = this.inputMateriel.allList;
                var results = queryString ? restaurants.filter(this.createStateFilter(queryString)) : restaurants;
                cb(results);
            },
            createStateFilter(queryString) {
                return (state) => {
                return (state.value.toLowerCase().indexOf(queryString.toLowerCase()) === 0);
                };
            },
             handleSelect(item) {
                this.inputMateriel.dialogForm.pid=item.tid;
            },
            showDialog3(type){
                let self = this;
               self.camera.isShow=true;
            },
            handleCurrentChange1(val){//选中的原料
              let self =this;
              self.inputMateriel.dialogForm.name=val.tid;
            },
            deleteSelectMaterie(row){//删除选中物料
            let self = this;
             this.$confirm('确认删除吗?', '提示', {
                    confirmButtonClass: 'el-button--warning'
                }).then(() => {
                     api.delateMaterie(row.id).then(res=>{
                         self.getSelectMaterieList(self.inputMateriel.dialogForm.pid)
                          self.$message.success('删除成功!')
                     },error=>{
                          self.$message.error('删除失败!')
                     })
                })

            },
            updateMaterialCheck(){/**提交检验记录 */
                let self= this;
                api.updateMaterialCheck(self.inputMateriel.checkMaterial.list).then(res=>{
                    self.dialog2.isShow=false;
                    self.getSelectMaterieList(self.inputMateriel.dialogForm.pid);
                    self.$message.success('检验记录提交成功!');
                },error=>{
                     self.$message.error('检验记录提交失败!');
                })
            },
            addResult(){/**新增输出检查结果 */
                let self = this;
                  this.$confirm('是否确认新增输出结果?', '提示', {
                    confirmButtonClass: 'el-button--warning'
                }).then(() => {
                    api.addUpdateReult('insert',{pid:self.dialogList.tid}).then(res=>{
                    self.getResulteList();
                    self.$message.success(`新增输出结果成功`)
                },error=>{
                    self.$message.error(`新增输出结果失败`)
                })
                })

            },
            printCode(code){
            LODOP = getLodop();
            LODOP.PRINT_INIT();
            LODOP.ADD_PRINT_BARCODE(25,15,150,80,"Code93",code);
            LODOP.PREVIEW();
        }
    }
}
</script>

<style scoped>
    .text-center{
        text-align: center;
    }
    #parts .el-table--small {
        font-size: 13px;
    }

    #parts .el-table .cell,
    #parts .el-table th div {
        padding-left: 0;
        padding-right: 0;
    }

    #parts .el-tab-pane.dialog1 .el-form{
        margin-bottom: 30px;
    }
    #parts .formDemo{
        margin:24px auto;
    }
    #parts .formItem{
        font-size: 15px;
        padding:10px 0;
        margin-bottom: 18px;
        margin-right:10px;
        display:block;
    }
    #parts .formItem .formItemLabel{
        font-size: 15px;
        display: inline-block;
        text-align: right;
        margin-right:12px;
    }
.reference{
        margin-left:24px;
        color:#888;
    }
  #parts .formItem .formInput{
      width:200px;
  }
#parts  .formModle{
        width: 400px;
    }
    #parts  .cameraItem{
        width:100%;

    }
    #parts  .cameraItem .cameraContent{
        width:200px;
         height:200px;
         line-height:200px;
         border:1px dashed #d9d9d9;
         text-align: center;
         border-radius: 4px;
    }
     #parts  .cameraItem .cameraContent:hover{
        border:1px dashed #409eff;

     }
</style>
